home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / vtcl / doc / ExprLong.3 < prev    next >
Encoding:
Text File  |  1995-07-10  |  5.0 KB  |  127 lines

  1. '\"
  2. '\" Copyright (c) 1989-1993 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/tcl/man/RCS/ExprLong.3,v 1.11 93/04/17 15:31:16 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. '\"----------------------------------------------------------------------------
  24. '\"    @(#) ExprLong.3 26.1 93/10/22 SCOINC
  25. '\"
  26. '\"     Copyright (C) The Santa Cruz Operation, 1992-1993.
  27. '\"     This Module contains Proprietary Information of
  28. '\"    The Santa Cruz Operation, and should be treated as Confidential.
  29. '\"----------------------------------------------------------------------------
  30. .so ../man.macros
  31. .HS Tcl_ExprLong tclc 7.0
  32. .BS
  33. .SH NAME
  34. Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBool, Tcl_ExprString \- evaluate an expression
  35. .SH SYNOPSIS
  36. .nf
  37. \fB#include <tcl.h>\fR
  38. .sp
  39. int
  40. \fBTcl_ExprLong\fR(\fIinterp, string, longPtr\fR)
  41. .sp
  42. int
  43. \fBTcl_ExprDouble\fR(\fIinterp, string, doublePtr\fR)
  44. .sp
  45. int
  46. \fBTcl_ExprBoolean\fR(\fIinterp, string, booleanPtr\fR)
  47. .sp
  48. int
  49. \fBTcl_ExprString\fR(\fIinterp, string\fR)
  50. .SH ARGUMENTS
  51. .AS Tcl_Interp *booleanPtr
  52. .AP Tcl_Interp *interp in
  53. Interpreter in whose context to evaluate \fIstring\fR.
  54. .AP char *string in
  55. Expression to be evaluated.  Must be in writable memory (the expression
  56. parser makes temporary modifications to the string during parsing, which
  57. it undoes before returning).
  58. .AP long *longPtr out
  59. Pointer to location in which to store the integer value of the
  60. expression.
  61. .AP int *doublePtr out
  62. Pointer to location in which to store the floating-point value of the
  63. expression.
  64. .AP int *booleanPtr out
  65. Pointer to location in which to store the 0/1 boolean value of the
  66. expression.
  67. .BE
  68.  
  69. .SH DESCRIPTION
  70. .PP
  71. These four procedures all evaluate an expression, returning
  72. the result in one of four different forms.
  73. The expression is given by the \fIstring\fR argument, and it
  74. can have any of the forms accepted by the \fBexpr\fR command.
  75. The \fIinterp\fR argument refers to an interpreter used to
  76. evaluate the expression (e.g. for variables and nested Tcl
  77. commands) and to return error information.  \fIInterp->result\fR
  78. is assumed to be initialized in the standard fashion when any
  79. of the procedures are invoked.
  80. .PP
  81. For all of these procedures the return value is a standard
  82. Tcl result:  \fBTCL_OK\fR means the expression was succesfully
  83. evaluated, and \fBTCL_ERROR\fR means that an error occurred while
  84. evaluating the expression.  If \fBTCL_ERROR\fR is returned then
  85. \fIinterp->result\fR will hold a message describing the error.
  86. If an error occurs while executing a Tcl command embedded in
  87. the expression then that error will be returned.
  88. .PP
  89. If the expression is successfully evaluated, then its value is
  90. returned in one of four forms, depending on which procedure
  91. is invoked.
  92. \fBTcl_ExprLong\fR stores an integer value at \fI*longPtr\fR.
  93. If the expression's actual value is a floating-point number,
  94. then it is truncated to an integer.
  95. If the expression's actual value is a non-numeric string then
  96. an error is returned.
  97. .PP
  98. \fBTcl_ExprDouble\fR stores a floating-point value at \fI*doublePtr\fR.
  99. If the expression's actual value is an integer, it is converted to
  100. floating-point.
  101. If the expression's actual value is a non-numeric string then
  102. an error is returned.
  103. .PP
  104. \fBTcl_ExprBoolean\fR stores a 0/1 integer value at \fI*booleanPtr\fR.
  105. If the expression's actual value is an integer or floating-point
  106. number, then \fBTcl_ExprBoolean\fR stores 0 at \fI*booleanPtr\fR if
  107. the value was zero and 1 otherwise.
  108. .VS
  109. If the expression's actual value is a non-numeric string then
  110. it must be one of the values accepted by \fBTcl_GetBoolean\fR,
  111. such as ``yes'' or ``no'', or else an error occurs.
  112. .VE
  113. .PP
  114. \fBTcl_ExprString\fR returns the value of the expression as a
  115. string stored in \fIinterp->result\fR.
  116. .VS
  117. If the expression's actual value is an integer
  118. then \fBTcl_ExprString\fR converts it to a string using \fBsprintf\fR
  119. with a ``%d'' converter.
  120. If the expression's actual value is a floating-point
  121. number, then \fBTcl_ExprString\fR calls \fBTcl_PrintDouble\fR
  122. to convert it to a string.
  123. .VE
  124.  
  125. .SH KEYWORDS
  126. boolean, double, evaluate, expression, integer, string
  127.